package com.gewu.pm.widget.broccoli;

import android.graphics.Color;
import android.view.View;

import me.samlss.broccoli.PlaceholderParameter;

/**
 * 加载前占位布局
 * https://github.com/samlss/Broccoli
 */
public class PlaceholderHelper {
    private PlaceholderHelper() {
        throw new UnsupportedOperationException("Can not be instantiated.");
    }

    public static PlaceholderParameter getParameter(View view) {
        if (view == null) {
            return null;
        }
        int placeHolderColor = Color.parseColor("#dddddd");

        int id = view.getId();

        return new PlaceholderParameter.Builder()
                .setView(view)
                .setDrawable(DrawableUtils.createRectangleDrawable(placeHolderColor, 5))
                .build();

/*        if (id == R.id.tv_time || id == R.id.tv_dispatch || id == R.id.tv_transfer || id == R.id.tv_money
                || id == R.id.tv_rid_title || id == R.id.btn_recharge || id == R.id.tv_wallet_balance || id == R.id.tv_agreement) {//渐变 滚动
            return new PlaceholderParameter.Builder()
                    .setView(view)
                    .setDrawable(new BroccoliGradientDrawable(Color.parseColor("#DDDDDD"),
                            Color.parseColor("#CCCCCC"), 5, 1000, new LinearInterpolator()))
                    .build();
        } if (id == R.id.img_wallet_balance) {//圆 渐变 滚动
            return new PlaceholderParameter.Builder()
                    .setView(view)
                    .setDrawable(new BroccoliGradientDrawable(Color.parseColor("#DDDDDD"),
                            Color.parseColor("#CCCCCC"), 1000, new LinearInterpolator()))
                    .build();
        } if (id == R.id.tv_problem) {//圆
            return new PlaceholderParameter.Builder()
                    .setView(view)
                    .setDrawable(DrawableUtils.createOvalDrawable(placeHolderColor))
                    .build();
        }  else {//一般的
            return new PlaceholderParameter.Builder()
                    .setView(view)
                    .setDrawable(DrawableUtils.createRectangleDrawable(placeHolderColor, 5))
                    .build();
        }*/

    }
}
